﻿using System.Reflection;
using System.Web.Http;
using Autofac;
using Autofac.Integration.WebApi;
using Gfinder.Data;
using Gfinder.Service;

namespace Gfinder.Api.App_Start
{
    public static class IocConfig
    {
        public static IContainer Container { get; set; }
        public static void Register()
        {
            var container = new ContainerBuilder();
            var config = GlobalConfiguration.Configuration;
            container.RegisterApiControllers(Assembly.GetExecutingAssembly());
            container.RegisterModule<DataModule>();
            container.RegisterModule<ServiceModule>();
            Container = container.Build();
            config.DependencyResolver = new AutofacWebApiDependencyResolver(Container);
        }
    }
}